/**	CODE EVAL::Easy [Simple Sorting]
*	Sort numbers on their respective lines
*	Accept first argument as path to filename
*
*	Michael Pio Arroyo
*/

#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <string>
#include <vector>

int main(int argc, char** argv) {
	std::fstream file;
	std::string line;
	std::string word;
	std::vector<double> num;
	file.open("simplesort.txt");
	while(std::getline(file,line)) {
		for(std::string::iterator i=line.begin(); i!=line.end(); ++i) {
			// create list of numbers for this line
			if(*i == ' ') {
				// convert and add word to vector array
				num.push_back(atof(word.c_str()));
				word.clear();
			} else {
				// add next character to word array
				word.append(& *i);
			}
		}
		// eh.. once more to get the last number
		num.push_back(atof(word.c_str()));
		word.clear();
		// sort from least to greatest
		double temp;
		for(int j=0; j<num.size(); ++j) {
			for(int i=1; i<num.size(); ++i) {
				if(num.at(i-1) > (num.at(i))) {
					temp = num.at(i-1);
					num.at(i-1) = num.at(i);
					num.at(i) = temp;
				}
			}
		}
		for(int i=0; i<num.size(); ++i)
			printf("%2.3f ", num.at(i));
		num.clear();
		putchar('\n');
	}
	file.close();
	return 0;
}